<template>
  <div class="easyd-weixin-Box">

    <!--分类数据-->  
    <mt-popup
            v-model="popupVisible"
            position="bottom" class="mint-popup-center">   
                <div class="shopCategoryTitle">请选择商品分类</div>
                <div class="shopCategoryItem" v-for="item in shopCategoryData" v-on:click="shopCategoryClick">{{item.text}}</div>
    </mt-popup>


    <div class="inventoryManagerHeader">
      <div class="inventoryManagerHeaderCategory"  @click="showCategoryPop">全部分类
        <i class="fa fa-caret-down fa-lg"></i>
      </div>
      <div class="inventoryManagerHeaderRecord" @click="goInventoryRecord">库存记录</div>
    </div>
    <div class="inventoryManagerBox">
      <mt-loadmore
        :top-method="loadTop"
        :bottom-method="loadBottom"
        :bottom-all-loaded="allLoaded"
        ref="loadmore"
      >
        <div class="inventoryManagerItem" v-for="i in shopCount">
          <div class="inventoryManagerItemImage">
              <img :src="imageDemoUrl" v-lazy="imageDemoUrl" v-gallery>
          </div>
          <div class="inventoryManagerItemName">我是商品名称</div>
          <div class="inventoryManagerItemInput">
            <input type="text" placeholder="请输入库存量">
          </div>
          <div class="inventoryManagerItemBtn">更改</div>
        </div>
      </mt-loadmore>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      imageDemoUrl:"http://testfileupload.oss-cn-beijing.aliyuncs.com/shangpin1.jpg",
      popupVisible : false,
      shopCount : 15,
      allLoaded : false,
      shopCategoryData : [
          { text : "家用电器" },
          { text : "手机/运营商/数码" },
          { text : "电脑/办公" },
          { text : "男装/女装/童装/内衣" },
          { text : "房产/汽车" },
          { text : "图书/文具" },
          { text : "医疗保健" },
          { text : "机票/酒店" },
          { text : "工艺品" },
      ]
    };
  },
  methods: {
    shopCategoryClick(){

        function GetRandomNum(Min, Max) {
            var Range = Max - Min;
            var Rand = Math.random();
            return(Min + Math.round(Rand * Range));
        }

        this.$easyUtil.startLoading(this)
        setTimeout(()=>{
            this.$easyUtil.endLoading(this);
            this.shopCount = GetRandomNum(1,20);
        },1000)

        this.popupVisible = false;
    },
    showCategoryPop(){
        this.popupVisible = true;
    }, 
    loadTop() {
      setTimeout(() => {
        this.$refs.loadmore.onTopLoaded();
      }, 2000);
    },
    loadBottom() {
      setTimeout(() => {
        this.allLoaded = true;
        this.$refs.loadmore.onBottomLoaded();
      }, 5000);
    },
    goInventoryRecord(){
      this.$router.push({
        path : '/inventoryRecord'
      })
    }
  }
};
</script>

<style lang="stylus" scoped>
@import '~PUBLIC_CSS'
.mint-popup-center {
    width 100%
    height 300px
    background #fff
    border-radius 5px
    padding 5px
    -webkit-overflow-scrolling : touch;
    overflow auto
}

.shopCategoryTitle {
    width 100%
    height 40px
    background #eee
    margin-top -5px
    text-indent 15px
    line-height 40px
}

.shopCategoryItem {
    width 100%
    height 40px
    border-bottom 1px solid #eee
    line-height 40px
    text-indent 15px
    
    &:last-child {
        height 35px
        border-bottom none
    }
}

.inventoryManagerBox {
  position: absolute;
  top: 50px;
  bottom: 0px;
  left: 0px;
  right: 0px;
  overflow: auto;
  -webkit-overflow-scrolling : touch;
  padding-top 15px
  padding-left: 15px;
  padding-right: 15px;

  .inventoryManagerItem {
    width: 100%;
    height: 80px;
    box-sizing: border-box;
    padding-top: 10px;
    padding-left: 10px;
    margin-bottom: 15px;
    $itemStyle()


    .inventoryManagerItemImage {
      width: 90px;
      height: 60px;
      background: #eee;
      float: left;

      img {
          width 100%
          height 100%
          object-fit  cover
          border-radius 5px
      }
    }

    .inventoryManagerItemName {
      width: 215px;
      height: 20px;
      margin-left: 10px;
      float: left;
    }

    .inventoryManagerItemInput {
      width: 130px;
      height: 30px;
      margin-top: 10px;
      margin-left: 10px;
      background: #fff;
      float: left;

      input {
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        outline: none;
        border-radius: 5px;
        border: 1px solid #eee;
        -webkit-appearance: none;
        padding: 10px;
      }
    }

    .inventoryManagerItemBtn {
      width: 80px;
      height: 30px;
      margin-right: 10px;
      float: right;
      text-align: center;
      line-height: 30px;
      margin-top: 10px;
      border-radius: 5px;
      background: #FDDE6E;
    }
  }
}

.inventoryManagerHeader {
  width: 100%;
  height: 50px;
  padding-left: 15px;
  background #fff
  padding-right: 15px;
  box-sizing: border-box;
  box-shadow: 0px 20px 50px #eee;

  .inventoryManagerHeaderCategory {
    width: 50%;
    float: left;
    height: 50px;
    line-height: 50px;

    i {
      margin-left: 5px;
      color: #999;
    }
  }

  .inventoryManagerHeaderRecord {
    width: 50%;
    float: left;
    text-align: right;
    height: 50px;
    line-height: 50px;
  }
}
</style>

